Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] #246 - 자동 로그인 버그 해결 #251

Merged
merged 8 commits into from
Dec 29, 2021

Conversation

mini-min
Copy link
Member

@mini-min mini-min commented Dec 28, 2021

🌴 PR 요약

🌱 작업한 브랜치

🌱 작업한 내용

  • basicHeader 강제 언래핑 에러가 발생해서 Const에 공통 상수로 뽑아두었습니다. -> 더 좋은 방법이 있을까요..? 일단 지난번에도 보셨겠지만, 옵셔널 바인딩은 안되는거 같더라구요...
  • UserDefaults 추가 -> isKakao, isApple(로그인 어느 것을 선택했는지 구분하기 위함)
  • 자체(애플, 카카오)적으로 연결을 끊을 시, 토큰 연결을 토대로 로그인부터 진행하도록 로직 추가 (AppDelegate)
  • 민재 담당 ServiceConst header를 가져오는 것으로 수정
  • 자동 로그인 로직과 화면전환은 splash에서 담당하는 것으로 변경 -> 팍하면서 화면 전환되었던 이슈 해결

📮 관련 이슈

@mini-min mini-min added Minjae 🐻‍❄️ 민재 강남1타강사 작업 P1 / Priority High 우선순위 높음 Fix 코드 수정 및 버그, 오류 해결 labels Dec 28, 2021
@mini-min mini-min self-assigned this Dec 28, 2021
@@ -8,5 +8,5 @@
import Foundation

struct Const {

static let headerToken: String = UserDefaults.standard.string(forKey: Const.UserDefaultsKey.accessToken) ?? ""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

선배 덕에 도약이야. 크

Comment on lines 13 to +16
static var bearerHeader = ["Authorization": "Bearer " + UserDefaults.standard.string(forKey: Const.UserDefaultsKey.accessToken)!]

static var basicHeader = ["Content-Type": "application/json",
"Authorization": "Bearer " + UserDefaults.standard.string(forKey: Const.UserDefaultsKey.accessToken)!]
"Authorization": "Bearer " + headerToken]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요부분도 동일하게 적용해주어야할거 같아요!
어차피 로그인에서는 basicHeader 만 쓰겠지만 같은 값을 다르게 표시한 부분을 피할 수 있을거 같아요!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요부분이라면 bearerHeder 말씀하시는건가요 선배??

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵!

Comment on lines +19 to +20
static let isAppleLogin = "isAppleLogin"
static let isKakaoLogin = "isKakaoLogin"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋았다 선배야

Comment on lines +65 to +69
// 앱 실행 중 애플 ID 강제로 연결 취소 시
NotificationCenter.default.addObserver(forName: ASAuthorizationAppleIDProvider.credentialRevokedNotification, object: nil, queue: nil) { (Notification) in
print("Revoked Notification")
self.isLogin = false
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

애플은 이렇게 하면되는데 카카오는 앱에서 연결끊기가 가능하지 카카오에서 연결을 끊으면 알아볼 방법이 없어보여요,,, 일단 전자의 경우 출처임당..

https://developers.kakao.com/docs/latest/ko/kakaologin/ios#unlink

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

맞습니다....

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

허허.. 뭔가 근데 애플은 앱에서 연결을 끊는게 없고 애플에서 끊으면 확인하는게 있고 / 카카오는 앱에서 연결을 끊는게 있고 카카오에서 끊은걸 확인하는게 없고 난리부르스네 일단 요거 생각안하구 되는데로 해두고 얘기해보자구요

Comment on lines +99 to +100
case .groupReset:
return Const.Header.basicHeader
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines -79 to -93
if AuthApi.hasToken() { // 유효한 토큰 존재
UserApi.shared.accessTokenInfo { (_, error) in
if let error = error {
if let sdkError = error as? SdkError, sdkError.isInvalidTokenError() == true {
// 로그인 필요
self.signUp()
}
} else {
// 토큰 유효성 체크 성공(필요 시 토큰 갱신됨)
self.signUp()
}
}
// 카카오톡 설치 여부 확인
if UserApi.isKakaoTalkLoginAvailable() {
// 카카오톡 로그인. api 호출 결과를 클로저로 전달.
loginWithApp()
} else {
// 카카오 토큰 없음 -> 로그인 필요
self.signUp()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아.. 원래 로직은 버튼 클릭해서 토큰 확인했었군여? 굳굳 깔끔해졌어여

Comment on lines +22 to +29
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

// Do any additional setup after loading the view.
// postUserTokenReissue(request: UserTokenReissueRequset(accessToken: UserDefaults.standard.string(forKey: Const.UserDefaults.accessToken)!, refreshToken: UserDefaults.standard.string(forKey: Const.UserDefaults.refreshToken)!))
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 1) {
if self.appDelegate?.isLogin == true {
self.presentToMain()
} else {
self.presentToLogin()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

쵝오

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

디패큐!!!!

Copy link
Member

@dlwns33 dlwns33 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LZTM!

Comment on lines +22 to +29
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

// Do any additional setup after loading the view.
// postUserTokenReissue(request: UserTokenReissueRequset(accessToken: UserDefaults.standard.string(forKey: Const.UserDefaults.accessToken)!, refreshToken: UserDefaults.standard.string(forKey: Const.UserDefaults.refreshToken)!))
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 1) {
if self.appDelegate?.isLogin == true {
self.presentToMain()
} else {
self.presentToLogin()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

디패큐!!!!


}

override func viewWillAppear(_ animated: Bool) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

스플래쉬는 좋겠다... 뷰 윌 어피어도 되고... 시무룩

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ..ㅜ

@mini-min mini-min merged commit 9326a50 into TeamNADA:release1.0/3 Dec 29, 2021
@mini-min mini-min deleted the release/#246 branch December 30, 2021 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fix 코드 수정 및 버그, 오류 해결 Minjae 🐻‍❄️ 민재 강남1타강사 작업 P1 / Priority High 우선순위 높음
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FIX] 자동 로그인 버그 해결
3 participants